import {ProColumns} from "@ant-design/pro-table";
import {IndexData} from "@/pages/system/tool/gen/add/interfaces";
import {indexMethod, indexType} from "@/utils";
import {Select, SelectProps} from "antd";

// @ts-ignore
export const columns: ProColumns<IndexData>[] = (genFieldList: SelectProps["options"]) => [
  {
    title: "锁引名称",
    dataIndex: "indexName",

  },
  {
    title: "锁引字段",
    dataIndex: "indexField",
    // @ts-ignore
    renderFormItem: (schema, config, form, action) => {
      return (<Select mode={"multiple"}
                      options={genFieldList}
                      onChange={(e: any[]) => {
                        schema.entity.indexName = e.join(",")
                      }}></Select>)
    },
    formItemProps: {
      rules: [
        {
          required: true,
          message: "名称是必须的"
        }
      ]
    }

  },
  {
    title: "锁引类型",
    dataIndex: "indexType",
    valueType: "select",
    initialValue: indexType.NORMAL,
    valueEnum: indexType,
    formItemProps: {
      rules: [
        {
          required: true,
          message: "类型是必须的"
        }
      ]
    }
  },
  {
    title: "锁引方法",
    dataIndex: "indexMethod",
    valueType: "select",
    initialValue: indexMethod.BTREE,
    valueEnum: indexMethod,
    formItemProps: {
      rules: [
        {
          required: true,
          message: "方法是必须的"
        }
      ]
    }

  },
  {
    title: "锁引描述",
    dataIndex: "indexDesc",
  },
  {
    title: '操作',
    valueType: 'option',
    align: 'center',
    render: () => {
      return null;
    },
  },
]
